package team.archai.nexus.flow.constant;

import team.archai.nexus.flow.vo.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 流程静态常量
 *
 * @author li shi bin
 */
public class ProcessConstant {

    private static final AssigneeTypeVO ASSIGNER = new AssigneeTypeVO();
    private static final AssigneeTypeVO CANDIDATE = new AssigneeTypeVO();
    private static final AssigneeTypeVO CANDIDATE_GROUPS = new AssigneeTypeVO();
    private static final ConditionCategoryVO DEFAULT_CATEGORY = new ConditionCategoryVO();
    private static final ConditionCategoryVO CUSTOM_CATEGORY = new ConditionCategoryVO();
    private static final ConditionVO SUCCESS = new ConditionVO();
    private static final ConditionVO FAILED = new ConditionVO();
    private static final FlowNodeVO START_NODE = new FlowNodeVO();
    private static final FlowNodeVO USER_TASK_NODE = new FlowNodeVO();
    private static final FlowNodeVO SERVICE_TASK_NODE = new FlowNodeVO();
    private static final FlowNodeVO EXCLUSIVE_GATEWAY_TASK_NODE = new FlowNodeVO();
    private static final FlowNodeVO END_NODE = new FlowNodeVO();
    private static final FlowListenerVO DEFAULT_LISTENER = new FlowListenerVO();
    private static final FlowListenerVO DEFAULT_EXEC_LISTENER = new FlowListenerVO();
    public static final List<AssigneeTypeVO> ASSIGNEE_TYPE_LIST = new ArrayList<>(3);
    public static final List<ConditionCategoryVO> CONDITION_CATEGORIES = new ArrayList<>(2);
    public static final List<ConditionVO> CONDITIONS = new ArrayList<>(2);
    public static final List<FlowNodeVO> FLOW_NODES = new ArrayList<>(3);
    public static final List<FlowListenerVO> TASK_LISTENERS = new ArrayList<>();
    public static final List<FlowListenerVO> EXEC_LISTENERS = new ArrayList<>();


    static {
        ASSIGNER.setValue("1");
        ASSIGNER.setKey("activiti:assignee");
        ASSIGNER.setLabel("指定人");
        CANDIDATE.setValue("2");
        CANDIDATE.setKey("activiti:candidateGroups");
        CANDIDATE.setLabel("候选用户");
        CANDIDATE_GROUPS.setValue("3");
        CANDIDATE_GROUPS.setKey("activiti:candidateGroups");
        CANDIDATE_GROUPS.setLabel("候选角色");
        DEFAULT_CATEGORY.setValue("1");
        DEFAULT_CATEGORY.setLabel("内置条件");
        DEFAULT_CATEGORY.setKey("default");
        CUSTOM_CATEGORY.setValue("2");
        CUSTOM_CATEGORY.setLabel("自定义");
        CUSTOM_CATEGORY.setKey("custom");
        FAILED.setValue("0");
        FAILED.setLabel("否");
        FAILED.setKey("n");
        FAILED.setCategory(1);
        SUCCESS.setValue("1");
        SUCCESS.setLabel("是");
        SUCCESS.setKey("y");
        SUCCESS.setCategory(1);
        START_NODE.setText("申请");
        START_NODE.setIconClass("icon-[mdi--circle-outline]");
        START_NODE.setEvent("addNode");
        START_NODE.setBpmnEventName("bpmn:startEvent");

        SERVICE_TASK_NODE.setText("服务任务");
        SERVICE_TASK_NODE.setIconClass("icon-[carbon--service-id]");
        SERVICE_TASK_NODE.setEvent("addNode");
        SERVICE_TASK_NODE.setBpmnEventName("bpmn:serviceTask");

        EXCLUSIVE_GATEWAY_TASK_NODE.setText("条件网关");
        EXCLUSIVE_GATEWAY_TASK_NODE.setIconClass("icon-[icon-park-outline--exclusive-gateway]");
        EXCLUSIVE_GATEWAY_TASK_NODE.setEvent("addNode");
        EXCLUSIVE_GATEWAY_TASK_NODE.setBpmnEventName("bpmn:exclusiveGateway");

        END_NODE.setText("结束");
        END_NODE.setIconClass("icon-[mdi--stop-circle-outline]");
        END_NODE.setEvent("addNode");
        END_NODE.setBpmnEventName("bpmn:endEvent");

        USER_TASK_NODE.setText("审批");
        USER_TASK_NODE.setIconClass("icon-[mdi--account-box-outline]");
        USER_TASK_NODE.setEvent("addNode");
        USER_TASK_NODE.setBpmnEventName("bpmn:userTask");
        DEFAULT_EXEC_LISTENER.setValue("1");
        DEFAULT_EXEC_LISTENER.setKey("team.archai.nexus.flow.listener.DefaultExecListener");
        DEFAULT_EXEC_LISTENER.setLabel("默认流程监听");
        DEFAULT_EXEC_LISTENER.setType(1);
        DEFAULT_EXEC_LISTENER.setStep("create");
        DEFAULT_LISTENER.setValue("1");
        DEFAULT_LISTENER.setKey("team.archai.nexus.flow.listener.DefaultExecListener");
        DEFAULT_LISTENER.setLabel("默认流程监听");
        DEFAULT_LISTENER.setType(2);
        DEFAULT_LISTENER.setStep("start");
        ASSIGNEE_TYPE_LIST.add(ProcessConstant.ASSIGNER);
        ASSIGNEE_TYPE_LIST.add(ProcessConstant.CANDIDATE);
        ASSIGNEE_TYPE_LIST.add(ProcessConstant.CANDIDATE_GROUPS);
        CONDITION_CATEGORIES.add(ProcessConstant.DEFAULT_CATEGORY);
        CONDITION_CATEGORIES.add(ProcessConstant.CUSTOM_CATEGORY);
        CONDITIONS.add(ProcessConstant.SUCCESS);
        CONDITIONS.add(ProcessConstant.FAILED);
        FLOW_NODES.add(ProcessConstant.START_NODE);
        FLOW_NODES.add(ProcessConstant.USER_TASK_NODE);
        FLOW_NODES.add(ProcessConstant.SERVICE_TASK_NODE);
        FLOW_NODES.add(ProcessConstant.EXCLUSIVE_GATEWAY_TASK_NODE);
        FLOW_NODES.add(ProcessConstant.END_NODE);
        TASK_LISTENERS.add(ProcessConstant.DEFAULT_LISTENER);
        EXEC_LISTENERS.add(ProcessConstant.DEFAULT_EXEC_LISTENER);

    }
}
